import Vue from 'vue';
import VueRouter from 'vue-router';
import Main from "../views/Main";
import Login from "../views/Login";
import UserProfile from "../views/user/Profile";
import UserList from "../views/user/List";
import NotFound from "../views/NotFound";

Vue.use(VueRouter);

export default new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/main/:username',
      component: Main,
      props: true,
      // 嵌套路由
      children: [
        {path: '/user/profile/:id', name: 'UserProfile', component: UserProfile},
        {path: '/user/list/:id', name: 'UserList', component: UserList, props: true}
      ]
    },
    {
      path: '/login',
      component: Login
    },
    {
      // 重定向，返回到主页
      path: '/goHome',
      redirect: '/main'
    },
    {
      // 匹配到以上之外的路径就走 *
      path: '*',
      component: NotFound
    }
  ]
});
